package com.itcast.excel.test;


import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.metadata.Sheet;

import java.io.*;
import java.util.*;

public class SubRunnable implements Runnable {
    Map<String, List<List<String>>> map1 = new HashMap<>();
    public SubRunnable(Map<String, List<List<String>>> map1){
        this.map1=map1;
    }
    @Override
    public void run() {
        synchronized (SubRunnable.class) {
            InputStream inputStream=null;
            try {
                 inputStream = new BufferedInputStream(new FileInputStream(new File("C:\\Users\\李赛飞\\Desktop\\11年.xlsx")));
                Sheet sheet = new Sheet(1, 1);
                List<Object> list = EasyExcelFactory.read(inputStream, sheet);

                Set<String> set = new HashSet<>();
                //Map<String, List<List<String>>> map1 = new HashMap<>();

                for (Object o : list) {
                    List<List<String>> listList = new ArrayList<>();
                    List<String> list1 = (List<String>) o;
                    boolean b = set.add(list1.get(7));
                    if (!b) {
                        map1.get(list1.get(7)).add(list1);
                    } else {
                        listList.add(list1);
                        map1.put(list1.get(7), listList);
                    }
                }
            }catch (IOException ex){
                ex.printStackTrace();
            }finally {
                try {
                    inputStream.close();
                }catch (IOException io){
                    io.printStackTrace();
                }

            }
        }
    }
}
